package ruifeng.zcj.dig.ui.vehicle;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import cn.bingoogolapple.androidcommon.adapter.BGARecyclerViewAdapter;
import cn.bingoogolapple.androidcommon.adapter.BGARecyclerViewHolder;
import cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper;
import ruifeng.zcj.dig.R;
import ruifeng.zcj.dig.ui.base.RefreshRecyclerFragment;
import ruifeng.zcj.dig.ui.vehicle.bean.NewVehicle;
import ruifeng.zcj.mybase.base.utils.GlideUtil;

/**
 * 二手车的list
 * Created by Administrator on 2016/9/27 0027.
 */
public class NewVehicleFragment  extends RefreshRecyclerFragment {

    @Override
    protected void initFragmentConfig(View view) {
        super.initFragmentConfig(view);

        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

    }
    @Override
    protected BGARecyclerViewAdapter getAdapter() {
        return new MomentAdapter2(recyclerView);
    }

    @Override
    public void onRVItemClick(ViewGroup parent, View itemView, int position) {
        showSnackBar("点击了item"+position);
    }

    @Override
    public boolean onRVItemLongClick(ViewGroup parent, View itemView, int position) {
        return false;
    }

    @Override
    protected void onFirstUserVisible() {
        List<NewVehicle> rows = new ArrayList<NewVehicle>();
        NewVehicle newVehicle = new NewVehicle();
        rows.add(newVehicle);
        rows.add(newVehicle);
        rows.add(newVehicle);
        rows.add(newVehicle);

        if (mMomentAdapter != null) {
            mMomentAdapter.addNewData(rows);
        }

    }

    @Override
    protected void onUserVisible() {

    }

    @Override
    protected void onUserInvisible() {

    }

    @Override
    protected void cleanMemory() {

    }

    public class MomentAdapter2 extends BGARecyclerViewAdapter<NewVehicle> {

        public MomentAdapter2(RecyclerView recyclerView) {
            super(recyclerView, R.layout.listview_item_vehicle);
        }

        @Override
        public void fillData(BGAViewHolderHelper helper, int position, NewVehicle moment) {
            /*if (TextUtils.isEmpty(moment.content)) {
                helper.setVisibility(R.id.tv_item_moment_content, View.GONE);
            } else {
                helper.setVisibility(R.id.tv_item_moment_content, View.VISIBLE);
                helper.setText(R.id.tv_item_moment_content, moment.content);
            }*/
            ImageView imageView = helper.getImageView(R.id.vehicle_fragment_item_img);
            GlideUtil.loadImage(mContext,"https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png",imageView);

            helper.setText(R.id.vehicle_fragment_item_title,"工地上的奇葩规律");
            helper.setText(R.id.vehicle_fragment_item_address,"工地上的奇葩规律");
            helper.setText(R.id.vehicle_fragment_item_price1,"价格");
            helper.setText(R.id.vehicle_fragment_item_price,"￥ 13万");
            helper.setText(R.id.vehicle_fragment_item_text_time,"2016/05/03");

          /*
          /*
            /*TextView postingsname = helper.getView(R.id.forum_fragment_item_text_title);

            BGANinePhotoLayout ninePhotoLayout = helper.getView(R.id.npl_item_moment_photos);

            ninePhotoLayout.init(MomentListActivity.this);
            ninePhotoLayout.setDelegate(MomentListActivity.this);
            ninePhotoLayout.setData(moment.photos);*/
        }

        @Override
        public void onViewRecycled(BGARecyclerViewHolder holder) {
            super.onViewRecycled(holder);

           /* BGANinePhotoLayout ninePhotoLayout = holder.getViewHolderHelper().getView(R.id.npl_item_moment_photos);
            ninePhotoLayout.init(null);
            ninePhotoLayout.setDelegate(null);*/
        }
    }

}
